package com.hippo.core.ui.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun SimpleTextEdit(
    value: String?= null,
    hint: String? = null,
    singleLine: Boolean = true,
    enable: Boolean = true,
    onValueChange: (String) -> Unit,
    textStyle:TextStyle = TextStyle(
        color = Color.Black,
        fontSize = 16.sp,
        textAlign = TextAlign.Center,
    ),
    modifier: Modifier = Modifier,
    keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
    keyboardActions: KeyboardActions = KeyboardActions.Default,
) {

    BasicTextField(
        value = value.orEmpty(),
        onValueChange = onValueChange,
        enabled = enable,
        modifier = modifier,
        singleLine = singleLine,
        keyboardOptions = keyboardOptions,
        keyboardActions = keyboardActions,
        textStyle = textStyle,
        decorationBox = { innerTextField ->
           Box(
               contentAlignment = androidx.compose.ui.Alignment.CenterStart,
               modifier = modifier
                   .border(1.dp, Color.LightGray, shape = RoundedCornerShape(4.dp))
                   .padding(16.dp)
           ) {
               innerTextField()
           }
        }
    )

}